﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BA2009.DataAccess.Context;
using BA2009.Entities;
using System.Collections;

namespace BA2009.Data.DataAccess
{
    public class ValueNameRepository<T> : IValueNameRepository<T>
        where T : IValueName, new()
    {

        protected BA2009Context _db;

        public ValueNameRepository()
        {

            _db = new BA2009Context(BA2009.Context.Constants.CONNECTION_STRING);
        }

        public IEnumerable<T> FindAll()
        {
            T t = new T();
            
            string query = string.Format("SELECT * FROM {0}", t.GetTableName());

            IEnumerable<T> result = _db.ExecuteQuery<T>(query);

          

            //var test = result.ToList();
            ////return objs;

            return result;

        }


    }
}
